/*
 * @Author: your name
 * @Date: 2020-08-24 17:29:21
 * @LastEditTime: 2020-08-27 14:16:48
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \examlist\src\store\ViewQuestions\ViewQuestions.js
 */
// store 文件
import { getAllExams, EditExams, getAllType, getAllQuestionsType, getAllExamType, SearchExams } from '../../api/ViewQuestions'
const state = {
  // 课程类型
  examType: [],

  // 考试试卷
  examList: [],
  // 题目类型
  QuestionsTypes: [],
  //  考试类型
  AllExamTypes: []
}
const mutations = {
  // 设置课程类型
  setExamType(state, payload) {
    state.examType = payload
  },
  // 设置考试试卷
  setExamList(state, payload) {
    state.examList = payload
  },
  // 设置考试类型
  setlQuestionsType(state, payload) {
    state.QuestionsTypes = payload
  },
  // 设置题目类型
  setAllExamType(state, payload) {
    state.AllExamTypes = payload
  }

}
const actions = {
  // 获取考试类型数据
  async getExamType({ commit }) {
    const { data: res } = await getAllType()
    // console.log(res)
    commit('setExamType', res.data)
  },
  async getExamList({ commit }) {
    const { data: res } = await getAllExams()
    // console.log(res)
    commit('setExamList', res.data)
  },
  async QuestionsType({ commit }) {
    const { data: res } = await getAllQuestionsType()
    console.log(res)
    commit('setlQuestionsType', res.data)
  },
  async AllExamType({ commit }) {
    const { data: res } = await getAllExamType()
    console.log(res)
    commit('setAllExamType', res.data)
  },
  async SearchValue({ commit }, data) {
    const { data: res } = await SearchExams(data)
    console.log(res)
    commit('setExamList', res.data)
  },
  // 编辑
  async EditExams(context, data) {
    console.log(data)
    const { data: res } = await EditExams(data)
    console.log(res)
  }
}
export default {
  namespaced: true,
  state,
  mutations,
  actions
}
